#ifndef _MAPKNOWLEDGE_HH_
#define _MAPKNOWLEDGE_HH_
#include "Ant.hh"
#include "State.h"
#include "Map.hh"
#include <set>

extern CacheMap torus;


/// cache known information in case ants in range are lost
struct cache_state_info_t
{
  std::set<Ant> enemyHills;
  std::set<uLocation> myHills;
  std::set<uLocation> food;

  cache_state_info_t(void)
  {
  }
 
  /// update knowledge
  void update_map_knowledge_before_turn(State & state);

};



/// Count reachable enemies according to the rules if one ant of team is at loc
unsigned count_reachable_enemies(Map<Square> & map, uLocation sLoc, signed team);

/// evaluates if a position is expected to die next turn
bool will_die(Map<Square> & map, uLocation sLoc, signed team);

struct hive_estimator_t
{
  unsigned hive, guards;
  std::vector<uLocation> * p_myHills;
  std::vector<uLocation> * p_food;

  hive_estimator_t(void) :
    hive(0), guards(0),
    p_myHills(NULL), p_food(NULL)
  {
  }

  
  void init(std::vector<uLocation> & _myHills, std::vector<uLocation> & _food)
  {
    hive = _myHills.size();
    guards = 0;
    p_myHills = &_myHills;
    p_food = &_food;
  }
    
  /// food reserve management
  void update_hive_estimate_before_turn(State & state);
  /// food reserve management
  void update_hive_estimate_after_turn(State & state);
  
};


/// Hive estimate helper
bool this_food_is_for_me(Map<Square> & map, uLocation fLoc, signed team = 0);







#endif /* _MAPKNOWLEDGE_HH_ */
